<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // Object.assign() 合并对象 返回 新的对象 可以做对象浅拷贝
    var  obj1 = {
      a: 10,
      b: 20
    }
    /* var obj2 = {
      c: 20,
      d: 20
    }
    var obj3 = Object.assign(obj1,obj2);
    console.log(obj3); */
    // 浅拷贝
    /* var obj2 = Object.assign({},obj1);
    console.log(obj2);
    obj2.a = 30;
    console.log(obj1); */

    var obj2 = {
      ...obj1
    }
    console.log(obj2);
    obj2.a = 10000;
    console.log(obj1);

    // JSON.parse(JSON.stringify(obj1))
  </script>
</body>
</html>